package cn.anecansaitin.whimsy.client.entity.render;

import cn.anecansaitin.whimsy.Whimsy;
import cn.anecansaitin.whimsy.client.entity.model.SeismicSlamWaveModel;
import cn.anecansaitin.whimsy.common.entity.ow.SeismicSlamWave;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;

public class SeismicSlamWaveRender extends EntityRenderer<SeismicSlamWave> {
    private final SeismicSlamWaveModel model;
    private final ResourceLocation textureLocation = Whimsy.resource("textures/entity/ow/seismic_slam_wave.png");

    public SeismicSlamWaveRender(EntityRendererProvider.Context context) {
        super(context);
        model = new SeismicSlamWaveModel(context.bakeLayer(SeismicSlamWaveModel.LAYER_LOCATION));
    }

    @Override
    public ResourceLocation getTextureLocation(SeismicSlamWave entity) {
        return textureLocation;
    }

    @Override
    public void render(SeismicSlamWave entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
        super.render(entity, entityYaw, partialTick, poseStack, buffer, packedLight);
        poseStack.pushPose();
        poseStack.mulPose(Axis.YP.rotationDegrees(entityYaw));
        poseStack.mulPose(Axis.XN.rotationDegrees(entity.getXRot()));
        VertexConsumer vertexconsumer = buffer.getBuffer(model.renderType(getTextureLocation(entity)));
        model.renderToBuffer(poseStack, vertexconsumer, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1f);
        poseStack.popPose();
    }
}
